var glide = $('.slider').glide({
    //autoplay:true,//是否自动播放 默认值 true如果不需要就设置此值
    animationTime:500, //动画过度效果，只有当浏览器支持CSS3的时候生效
    arrows:false, //是否显示左右导航器
    arrowsWrapperClass: "arrowsWrapper",//滑块箭头导航器外部DIV类名
    arrowMainClass: "slider-arrow",//滑块箭头公共类名
    arrowRightClass:"slider-arrow--right",//滑块右箭头类名
    arrowLeftClass:"slider-arrow--left",//滑块左箭头类名
    arrowRightText:">",//定义左右导航器文字或者符号也可以是类
    arrowLeftText:"<",

    nav:true, //主导航器也就是本例中显示的小方块
    navCenter:true, //主导航器位置是否居中
    navClass:"slider-nav",//主导航器外部div类名
    navItemClass:"slider-nav__item", //本例中小方块的样式
    navCurrentItemClass:"slider-nav__item--current" //被选中后的样式
});



function ShowCountDown(starttime,endtime,ele,t){
    var endDate = new Date(endtime);
    var now = new Date();
    var cc = $(ele).find('.dateline');
    var tip = '剩余：';

    if(starttime>now){
        endDate = new Date(starttime);
        tip = "距离活动开始：";
    }

    if(endDate<=now){
        if(cc.html()!="<span>已结束！</span>")cc.html("<span>已结束！</span>");
        if($(ele).find('a.link').attr('href')!='javascript:void(0);')$(ele).find('a.link').attr('href','javascript:void(0);').attr('style','cursor: default;');
        clearInterval(t);
        return;
    }
    var leftTime=endDate.getTime()-now.getTime();
    var leftsecond = parseInt(leftTime/1000);
    var day1=Math.floor(leftsecond/(60*60*24));
    var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
    var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
    var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
    cc.html(tip+"<span>"+day1+"</span>天<span>"+hour+"</span>小时<span>"+minute+"</span>分<span>"+second+"</span>秒");
}

$('.zhuanchang').find('.box').each(function(index,ele) {
    var starttime = parseInt($(this).attr('data-starttime'));
    var endtime = parseInt($(this).attr('data-endtime'));
    ShowCountDown(starttime,endtime,ele);
    var _t = setInterval(function(){ShowCountDown(starttime,endtime,ele,_t)},1000);
});


